using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FiltronASP.Modules.Abstracts;
using FiltronASP.Models.DAO.Interfaces;
using System.Web.UI.WebControls;
using FiltronASP.Models;
using FiltronASP.Models.DAO.Filtron;
using FiltronASP.Models.DAO.Interfaces.Filtron;
using FiltronASP.Helpers;
using FiltronASP.Helpers.CatalogueMenu;

namespace FiltronASP.Modules
{
    public class applCarsSearchModuleFiltron : AbstractModule
    {
        private Page currentPage;
        /// <summary>
        /// Klasa odpowiedzialna za generowanie contentu przez modul.
        /// </summary>
        /// <param name="page">biezaca strona</param>
        /// <returns>content</returns>
        public override string GenerateContent(FiltronASP.Models.Page page)
        {
            this.currentPage = page;
            int pageId = page.page_id;
            int languageId = Convert.ToInt32(page.language_id);
            return this.generateBottomMenu(languageId, pageId) + this.generateInnerContent();
        }

        private string generateBottomMenu(int languageId, int pageId)
        {
            string htmlToReturn = "";
            htmlToReturn += "<div id=\"bottomMenu\">";
            htmlToReturn += "   <div class=\"selectMarketMenu\">";
            htmlToReturn += "       <span class=\"changeMarketInfo\">" + Helpers.XmlHelper.XMLHelper.readXML("currentMarketInfoFiltron", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</span>";
            htmlToReturn += "       <a href=\"" + Helpers.XmlHelper.XMLHelper.readXML("changeMarketLink", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "\" class=\"changeMarketButton\">" + Helpers.XmlHelper.XMLHelper.readXML("changeMarket", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</a>";
            htmlToReturn += "   </div>";
            htmlToReturn += "   <ul class=\"selectCarTypeMenu\">";

            htmlToReturn += CatalogueMenuHelper.generateMenuFiltron(languageId, pageId);


            htmlToReturn += "   </ul>"; //</selectCarTypeMenu>
            
            htmlToReturn += "<div id=\"selectCarTypeMenuUnder\">";
            htmlToReturn += "            <div class=\"selectCarTypeMenuUnderSingle\" >";
	        htmlToReturn += "    <label for=\"\">Grupa</label>";
            htmlToReturn += "        <select onchange=\"doFilterWork('groupDropDown', 'filterDropDown')\" id=\"groupDropDown\" name=\"brand\">";
            htmlToReturn += "           <option value=\"-1\" selected=\"selected\">" + Helpers.XmlHelper.XMLHelper.readXML("selectGroup", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</option>";
            IFiltronFilterTypeDAO filtronFilterTypeDAO = new FiltronFilterTypeDAO();
            IQueryable<FiltronFilterType> FilterTypeCollection = filtronFilterTypeDAO.FindAll();
            foreach (FiltronFilterType filterType in FilterTypeCollection) {
                htmlToReturn += "<option value=\"" + filterType.type_id + "\">" + filterType.type_abbr + " - " + filterType.type_name + "</option>";
            }

	        htmlToReturn += "    </select>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class=\"selectCarTypeMenuUnderSingle\" >";
	        htmlToReturn += "    <label for=\"\">Filtr</label>";
            htmlToReturn += "        <select onchange=\"doModelWork('filterDropDown', 'modelDropDown')\" name=\"brand\" id=\"filterDropDown\">";
            htmlToReturn += "           <option value=\"-1\" selected=\"selected\">" + Helpers.XmlHelper.XMLHelper.readXML("selectFilter", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</option>";
            htmlToReturn += "        </select>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class=\"selectCarTypeMenuUnderSingle\" >";
	        htmlToReturn += "    <label for=\"\">Model</label>";
            htmlToReturn += "        <select onchange=\"doTypeWork('modelDropDown', 'typeDropDown')\" id=\"modelDropDown\" name=\"brand\">";
            htmlToReturn += "            <option value=\"-1\" selected=\"selected\">" + Helpers.XmlHelper.XMLHelper.readXML("selectModel", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</option>";
		    htmlToReturn += "        </select>";
            htmlToReturn += "</div>";
            htmlToReturn += "<div class=\"selectCarTypeMenuUnderSingle\" >";
	        htmlToReturn += "    <label for=\"\">Typ</label>";
            htmlToReturn += "        <select onchange=\"doEngineWork(this)\" name=\"brand\"id=\"typeDropDown\">";
            htmlToReturn += "            <option value=\"-1\" selected=\"selected\">" + Helpers.XmlHelper.XMLHelper.readXML("selectType", Helpers.XmlHelper.XMLHelper.getLanguageNameById(Convert.ToInt32(this.currentPage.language_id))) + "</option>"; ;
		    htmlToReturn += "        </select>";
            htmlToReturn += "</div>";
            htmlToReturn += CatalogueMenuHelper.GenerateLastModifiedFiltron(this.currentPage.language_id);
            htmlToReturn += "</div>"; //</selectCarTypeMenuUnder>
            htmlToReturn += "</div>"; //</bottomMenu>            
            return htmlToReturn;
        }

        private string generateInnerContent()
        {
            string htmlToReturn = "";
            htmlToReturn += " <div id=\"contentHolderInner\">";
            htmlToReturn += this.generateEnginePart();
            return htmlToReturn;
        }

        private string generateEnginePart()
        {
            string htmlToReturn = "";
            htmlToReturn += "<div id=\"searchLeftSide\"></div>";
            htmlToReturn += "<div id=\"searchRightSide\">";
            htmlToReturn += "   <div class=\"searchRightSideTop\"></div>";
            htmlToReturn += "   <div id=\"searchRightSideBottom\"></div>";
            htmlToReturn += "</div>";
            htmlToReturn += "</div> <!-- #contentHolderInner -->"; // #contentHolderInner
            return htmlToReturn;
        }



    }
}
